package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.UserStatusInfo;
import com.tanhua.dubbo.api.UserStatusInfoApi;
import com.tanhua.dubbo.mapper.UserStatusInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserStatusInfoApiImpl implements UserStatusInfoApi {

    @Autowired
    private UserStatusInfoMapper userStatusInfoMapper;

    @Override
    public void saveStatus(UserStatusInfo userStatusInfo) {
        userStatusInfoMapper.insert(userStatusInfo);
    }

    @Override
    public void update(UserStatusInfo userStatusInfo) {
        QueryWrapper<UserStatusInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userStatusInfo.getUserId());
        userStatusInfoMapper.update(userStatusInfo,wrapper);
    }

    @Override
    public UserStatusInfo select(Integer userId) {
        QueryWrapper<UserStatusInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        UserStatusInfo userStatusInfo = userStatusInfoMapper.selectOne(wrapper);
        return userStatusInfo;
    }
}
